package com.demo.web;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;

import org.springframework.web.client.RestTemplate;

/**
 * Created by Lucicol on 2018/1/11.
 */
@RestController
public class HController {
    private int a;

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    @RequestMapping("/h")
    public String index() {
        a = 3;
        System.out.println(a);
        return "1";
    }

    @GetMapping("/wechart_ip")
    public void getAccessToken() {
        String access_token= "7_pOqIBIIcMeevTmk6DjS54hHQ_1H0LoTpgd0mJZBZFApROfWGbcaPizvdarLwrkaBgV8XAh8PaKlVAn3ITQ5qztJx55t0Nn07aZg2v2o7HkKLRmN4U9QhNNJtTAEIRPhABAMVT";
        String url = "https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token="+access_token;

        RestTemplate restTemplate = new RestTemplate();
        String response = restTemplate.getForObject(url, String.class);
        System.out.println(response);
    }

    @RequestMapping(value = "/menu", method = RequestMethod.POST)
    public void setMenu() {
        String access_token= "7_pOqIBIIcMeevTmk6DjS54hHQ_1H0LoTpgd0mJZBZFApROfWGbcaPizvdarLwrkaBgV8XAh8PaKlVAn3ITQ5qztJx55t0Nn07aZg2v2o7HkKLRmN4U9QhNNJtTAEIRPhABAMVT";
        String url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token="+access_token;

//        RestTemplate restTemplate = new RestTemplate();
//        String response = restTemplate.getForObject(url, String.class);
//        System.out.println(response);
    }
}
